<?php
class H_Model_Site extends Zend_Db_Table_Abstract implements H_Model_Interface_HasMeta{
    protected $_primary = 'id';
    protected $_name = "";
    protected $_siteMetaOb;
    private $_currentSiteId;
    const DEFAULT_LANG = 'default_lang';
    const PAGE_CACHE_TIME = 'page_cache_time';
    const SITE_OFF_MESSAGE = 'site_off_message';
    const SMTP_ENCRY = 'smtp_encryption';
    const SMTP_FROM_MAIL = 'smtp_from_mail';
    const SMTP_FROM_NAME = 'smtp_from_name';
    const SMTP_HOST = 'smtp_host';
    const SMTP_PASS = 'smtp_pass';
    const SMTP_PORT = 'smtp_port';
    const SMTP_USER = 'smtp_user';

    public function __construct($site_id) {
        parent::__construct();
        $dbconfig = $this->_db->getConfig();
        $this->_name = $dbconfig['prefix'].'site';
        $this->_siteMetaOb = new H_Model_SiteMeta();
        $this->_currentSiteId = $site_id;
    }
    public function getMeta($key) {
        return $this->_siteMetaOb->getSiteMeta($this->_currentSiteId, $key);
    }
    public function getAllMeta() {
        $data = $this->_siteMetaOb->getSiteAllMeta($this->_currentSiteId);       
        return H_Util_Array::metaArray($data, 'key', 'value');
    }
    public function getMetaValue($key) {
        return $this->_siteMetaOb->getSiteMetaValue($this->_currentSiteId, $key);
    }
    public function updateMeta($key,$value){
        return $this->_siteMetaOb->updateSiteMeta($this->_currentSiteId, $key, $value);
    }
}